import java.util.Scanner;

public class NowCoder2 {
    //给出一个有序的整数A 和一个有序的整数B  将b合并到a中 形成一个有序的升序数组  A能容纳B
    public static void mergeArr(int[] arr1, int i,int[] arr2,int j) {
        int k;
        i = i -1;
        j = j -1;
        k = arr1.length+arr2.length-1;
        //当两个数组都没有走完时 从后往前比较 将较大的元素放入到k位置 更新下标继续比较
        while (i >= 0 && j >= 0) {
            if(arr1[i] > arr2[j]){
                arr1[k--] = arr1[i--];
            }else
                arr1[k--] = arr2[j--];
        }
        //将剩下的非空数组合并到arr1
        while(i >= 0){
            arr1[k--] = arr1[i--];
        }
        while(j >= 0){
            arr1[k--] = arr2[j--];
        }
    }

    public static void main(String[] args) {
        int[] arr1 = new int[20];
        arr1[0] = 2;
        arr1[1] = 8;
        System.out.println(arr1.length);
        int arr2[] = {1,3,9,13,17,27,31,35};
        mergeArr(arr1,2,arr2,8);
        System.out.println(arr1.toString());
    }
}

